package com.niuwa.p2p.core.utils;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Locale;

/**
 * @ClassName: MessageUtil
 * @Description: 消息工具类
 * @author: jishengjun
 */
public class MessageUtil {

	/**
	 * 获取消息
	 * @return Properties
	 * @throws IOException
	 */
	public static String getMessage(String key)  {
		return  ApplicationContextUtil.getApplicationContext().getMessage(key, null, Locale.CHINA);
	}
	
	public static String getMessageUTF8(String key)  {
		return  encodeUtf8(ApplicationContextUtil.getApplicationContext().getMessage(key, null, Locale.CHINA));
	}

	/**
	 * 字符串转码
	 * 
	 * @param value
	 * @return
	 */
	public static String encodeUtf8(Object value) {
		String encodeValue = "";
		try {
			encodeValue = new String(String.valueOf(value).getBytes("ISO-8859-1"), "UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return encodeValue;
	}

}